class Solution(object):
    def isPowerOfTwo(self, n):
        """
        :type n: int
        :rtype: bool
        """
        result = 0

        while (n>0):
            result += n&1
            n >>= 1

        return result==1

a = Solution()
a.isPowerOfTwo(9)